/*
 *  cocoa/graphic2D.cpp
 *  mini
 *
 *  Created by jin on 1/1/11.
 *  Copyright 2011 cs. All rights reserved.
 *
 */

#include "cocoa/graphic2d.h"

CocoaGraphic2D::CocoaGraphic2D(CGContextRef cg_)
{
    cg = CGContextRetain(cg_);
}

CocoaGraphic2D::~CocoaGraphic2D()
{
    CGContextRelease(cg);
}

void CocoaGraphic2D::clear_rect(float x, float y, float w, float h)
{
    CGContextClearRect(cg, CGRectMake(x, y, w, h));
}

void CocoaGraphic2D::draw_line(float x0, float y0, float x1, float y1)
{
    CGPoint path[2] = { {x0, y0}, {x1, y1} };
    CGContextStrokeLineSegments(cg, path, 2);
}
